<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="../../mobileHeader_inc.jsp" %>
<title>发布失物招领</title>
</head>
<script type="text/javascript">
function btnSave_click() {
/* 	var file = $('#uploadFile')[0];
	var imagSize =  document.getElementById("uploadFile").files[0];
	var status =  document.getElementById("status").value;
	if(imagSize != null && imagSize != "" && !isNull( imagSize )){
		imagSize = imagSize.size;
	} */

	var fun_ret;
	var vals = $('#formModule').serialize();
	var url = '/manage/sysLostAndFound/addSave';
	var formData = new FormData($('#formModule')[0]);
	$.ajax({
		async : false,
		type : "POST",
		url : url,
		data : formData,
		cache : false,
		contentType : false,
		processData : false,
		dataType : 'json',
		xhr : function() { // custom xhr
			myXhr = $.ajaxSettings.xhr();
			if (myXhr.upload) { // if upload property exists
				myXhr.upload.addEventListener('progress',
						progressHandlingFunction, false); // progressbar
			}
			return myXhr;

		},
		//Ajax events
		success : function(data) {
               if(data.success == 0 )
               {
            	   fun_ret = true;
            	   alert("添加成功");
            	   window.location.href="${ctx}/mobile/LostAndFound";
               }
               else
               {
            	   alert("添加失败");
               }
           },
		error : errorHandler = function(data) {
			alert("添加失败");
			return false;
		}
	});
	return fun_ret;
}

function progressHandlingFunction(e) {
if (e.lengthComputable) {
	$('progress').attr({
		value : e.loaded,
		max : e.total
	});
}
}
</script>
<body>

<div>
  <header data-am-widget="header"
          class="am-header am-header-default joan-head">
      <div class="am-header-left am-header-nav">
          <a href="/mobile/LostAndFound" target="_self" class="">
                返回
          </a>
      </div>

      <h2 class="am-header-title">
          失物招领
      </h2>
  </header>
  
<form class="am-form" id="formModule" method="post">
<fieldset>
<div class="am-form-group">
      <label for="doc-select-1">选择丢失或捡到</label>
      <select id="doc-select-1">
        <option value="option1">我捡到</option>
        <option value="option2">我丢失</option>
      </select>
      <span class="am-form-caret"></span>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">标题:</label>
      <input type="text" class="" id="arcitleName" name="arcitleName">
    </div>
    <div class="am-form-group">
      <label for="doc-ta-2">详情:</label>
      <textarea class="" rows="5" id="iteminform" name="iteminform"></textarea>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-4">联系人:</label>
      <input type="text" class="" id="contactPerson" name="contactPerson">
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-5">联系方式:</label>
      <input type="tel" class="" id="contactPhone" name="contactPhone">
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-file-1">上传文件</label>
      <input type="file" id="uploadFile" name="uploadFile">
      <p class="am-form-help">请选择要上传的文件...</p>
    </div>
    <div align="center">
		<button type="submit" class="am-btn am-btn-default am-round" data-ajax="false" onclick="btnSave_click();" style="width:50%;">发布</button>
    </div>
    </fieldset>
</form>
  
  
  <hr data-am-widget="divider" style="" class="am-divider am-divider-default" />
  
</div>
</body>
</html>